import { S } from '../../s';
import { IPSDELogic } from './ipsdelogic';
import { IPSDELogicLinkSingleCond } from './ipsdelogic-link-single-cond';
import { IPSDELogicParam } from './ipsdelogic-param';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDELogicLinkSingleCondImpl
  extends PSModelObjectImpl
  implements IPSDELogicLinkSingleCond
{
  get condOP(): string {
    return this.M.condOP;
  }

  get dstFieldName(): string {
    return this.M.dstFieldName;
  }

  protected dstlogicparam: IPSDELogicParam;
  getDstLogicParam(): IPSDELogicParam | null {
    if (this.dstlogicparam != null) return this.dstlogicparam;
    const value = this.M.getDstLogicParam;
    if (value == null) {
      return;
    }
    const ipsdelogic = this.getParentPSModelObject(S._200) as IPSDELogic;
    if (ipsdelogic != null) {
      this.dstlogicparam = ipsdelogic.findPSDELogicParam(value);
    }
    return this.dstlogicparam;
  }

  get logicType(): 'GROUP' | 'SINGLE' {
    return this.M.logicType;
  }

  get paramType(): 'ENTITYFIELD' | 'CURTIME' {
    return this.M.paramType;
  }

  get paramValue(): string {
    return this.M.paramValue;
  }

  protected srclogicparam: IPSDELogicParam;
  getSrcLogicParam(): IPSDELogicParam | null {
    if (this.srclogicparam != null) return this.srclogicparam;
    const value = this.M.getSrcLogicParam;
    if (value == null) {
      return;
    }
    const ipsdelogic = this.getParentPSModelObject(S._200) as IPSDELogic;
    if (ipsdelogic != null) {
      this.srclogicparam = ipsdelogic.findPSDELogicParam(value);
    }
    return this.srclogicparam;
  }

  get value(): string {
    return this.M.value;
  }
  get cls(): string {
    return 'PSDELogicLinkSingleCondImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._1db) return true;
    return super.instanceof(cls);
  }
}
